package com.sky.web.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sky.domain.Book;
import com.sky.service.BookService;

public class QueryBookByManyConditionServlet extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      //获取请求参数，商品编号，商品名称，商品价格的范围，商品分类  (条件不固定)
		String id  =  request.getParameter("id");
		String category  =  request.getParameter("category");
		String name  =  request.getParameter("name");
		String minprice  =  request.getParameter("minprice");
		String maxprice  =  request.getParameter("maxprice");
	   //处理业务逻辑
		
		BookService bookService =new BookService();
		try {
			List<Book> list = bookService.queryBookByManyCondition(id,category,name,minprice,maxprice);
			request.setAttribute("booklist", list);
			request.getRequestDispatcher("product/list.jsp").forward(request, response);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
